<?php

//if( !defined( '_VALID_MOS' ) && !defined( '_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' );

define('ABSLPATH1', dirname(__FILE__).'/');
$joomla_root = substr(ABSLPATH1, 0, -56);

// Initialize Joomla framework
define( '_JEXEC', 1 );
define('JPATH_BASE', $joomla_root );
define( 'DS', '/' ); //DIRECTORY_SEPARATOR

//define('ABSLPATH2', dirname(__FILE__).'/');
//$shorten_path = substr(ABSLPATH2, 0, -56);
//$shorten_path_2 = $shorten_path;
//$shorten_path .= "includes\defines.php";
//$shorten_path_2 .= "includes\\framework.php";
$shorten_path .= JPATH_BASE .DS.'includes'.DS.'defines.php';
$shorten_path_2 .= JPATH_BASE .DS.'includes'.DS.'framework.php';
//echo $shorten_path . "<br /><br />";
//echo $shorten_path_2 . "<br /><br />";

$file = dirname(__FILE__) . "/ps_kreditor.common.cfg.php";
//echo $file . "<br /><br />";
require_once( $file );

if(file_exists($shorten_path) && file_exists($shorten_path_2))
{
	require_once($shorten_path);
	require_once($shorten_path_2);
	//activateLanguage();
}
else
{
	define('ABSLPATH3', dirname(__FILE__).'/');
	$shorten_path = substr(ABSLPATH3, 0, -57);
	$shorten_path_2 = $shorten_path;

	$shorten_path .= DS.'includes'.DS.'defines.php';
	$shorten_path_2 .= DS.'includes'.DS.'framework.php';
	//echo "ELSE: " . $shorten_path . "\n";
	//echo "ELSE: " . $shorten_path_2 . "\n";

	if(file_exists($shorten_path) && file_exists($shorten_path_2))
	{
		//require_once($shorten_path);
		//require_once($shorten_path_2);
		//activateLanguage();
	}
	//else
		//echo "Include error!<br />";
}

// Required Files
//require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
//require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );

function getValidCountrieCodes() {
	$array = array();

	if(KREDITOR_COUNTRIE_SWEDEN == "Y") { $array[] = "SWE";	}
	if(KREDITOR_COUNTRIE_GERMANY == "Y") { $array[] = "DEU"; }
	if(KREDITOR_COUNTRIE_FINLAND == "Y") { $array[] = "FIN"; }
	if(KREDITOR_COUNTRIE_NORWAY == "Y") { $array[] = "NOR"; }
	if(KREDITOR_COUNTRIE_DENMARK == "Y") { $array[] = "DNK"; }
	if(KREDITOR_COUNTRIE_NETHERLAND == "Y") { $array[] = "NLD"; }

	return $array;
}

function getJoomlaOrElseVendorLanguage() {
	$config = &JFactory::getConfig();
	$lang = strtolower($config->getValue('language'));
	$joomlaLang;
	if(strstr($lang, 'de') || strstr($lang, 'de')) {
		$joomlaLang = 'DEU';
	} else if(strstr($lang, 'sv') || strstr($lang, 'se')) {
		$joomlaLang = 'SWE';
	} else if(strstr($lang, 'fi') || strstr($lang, 'fi')) {
		$joomlaLang = 'FIN';
	} else if(strstr($lang, 'da') || strstr($lang, 'dk')) {
		$joomlaLang = 'DNK';
	} else if(strstr($lang, 'nb') || strstr($lang, 'no')) {
		$joomlaLang = 'NOR';
	} else if(strstr($lang, 'nl') || strstr($lang, 'nl')) {
		$joomlaLang = 'NLD';
	} else {
		$db2 = new ps_DB;
		$q2 = "SELECT vendor_country FROM #__{vm}_vendor WHERE vendor_id = '" . $_SESSION['ps_vendor_id'] . "';";
		$db2->query($q2);
		$joomlaLang = $db2->f("vendor_country");
	}
	return $joomlaLang;
}

function activateLanguage()
{
	$db =& JFactory::getDBO();
	// if ($db->connected()) {
	   // echo 'you are connected to the Joomla database';
	// }

	$dbCountrie = new ps_DB;
	$q  = "SELECT * from #__{vm}_user_info WHERE user_id='" . $_SESSION['auth']['user_id'] . "' AND address_type='BT'";
	$dbCountrie->query($q);
	$living_in_country = $dbCountrie->f('country');

	if(in_array($living_in_country, getValidCountrieCodes())) {
		$langObj = new KRED_Language();
		$langObj->setLanguage($living_in_country);
		$setLang = "setLanguage=" . $living_in_country;
		?><script type="text/javascript">document.cookie = "<?php echo $setLang ?>";</script><?php
	} else {
		$living_in_country = getJoomlaOrElseVendorLanguage();
		if(isset($living_in_country) && in_array($living_in_country, getValidCountrieCodes())) {
			$langObj = new KRED_Language();
			$langObj->setLanguage($living_in_country);
			$setLang = "setLanguage=" . $living_in_country;
			?><script type="text/javascript">document.cookie = "<?php echo $setLang ?>";</script><?php
		}
	}
}

class KRED_Language
{
    public function setLanguage($strLang)
    {
		switch($strLang)
		{
			case "KRED_SEK":
			case "SEK":
			case "swe":
			case "SWE":
			case "SE":
			case "se":
			case "Swedish":
			case "swedish":
			case "Svenska":
			case "svenska":
				$langInfo = new Singleton("Swedish");
				$langInfo->TEXT_CHECKOUT_TITLE = "Betala i efterskott";
				$langInfo->TEXT_INVOICE_SOCIAL_NR = "Personnummer/Org. Nummer";
				$langInfo->TEXT_PAYMENT_GENDER = "Kön";
				$langInfo->TEXT_PAYMENT_GENDER_MALE = "Man";
				$langInfo->TEXT_PAYMENT_GENDER_FEMALE = "Kvinna";
				$langInfo->TEXT_SOCIAL_NR = "Personnummer";
				$langInfo->TEXT_PAYMENT_PHONE_NR_HOME = "Hemtelefon";
				$langInfo->TEXT_PAYMENT_PHONE_NR_MOBILE = "Mobiltelefon";
				$langInfo->TEXT_PAYMENT_EMAIL = "E-postadress";
				$langInfo->TEXT_PAYMENT_STREET_NAME = "Gatunamn";
				$langInfo->TEXT_PAYMENT_STREET_NUMBER = "Gatunummer";
				$langInfo->TEXT_PAYMENT_INVOICE_CONDITIONS = "Fakturavillkor";
				$langInfo->TEXT_PAYMENT_ANNUAL_SALARY = "Årsinkomst";
				$langInfo->TEXT_PAYMENT_TERMS = "Jag godkänner villkoren ";
				$langInfo->TEXT_PAYMENT_LINK_TERMS = "kontovillkoren";
				$langInfo->TEXT_PAYMENT_LINK_TERMS_2 = "";
				$langInfo->TEXT_PAYMENT_CHOOSE_MONTHLY_PAYMENT = "Välj antal månader";
				$langInfo->TEXT_PAYMENT_REQUIRED = "Rödmarkerade fält är obligatoriska";
				$langInfo->TEXT_ADRESS_UPDATE_ALERT = "Leveransadress uppdaterades till folkbokf. adr.";
				$langInfo->TEXT_INVOICE_COST = "Fakturaavgift";
				$langInfo->TEXT_INFO_MISSING = "Information saknas";
				$langInfo->TEXT_ACCEPT_CONDITIONS = "Du måste godkänna villkoren";
				$langInfo->TEXT_MONTHLY_COST = "Månadskostnad";
				$langInfo->TEXT_MONTHS = "Månader";
				$langInfo->LINK_CONDITIONS_PDF = "http://www.delauppbetalningen.se/kontovillkor.pdf";
				$langInfo->TEXT_CHECKOUT_ERR_BAD_PERSON_NR = "Fel format på personnummer/orgnummer";
				$langInfo->TEXT_CHECKOUT_ERR_NO_PERSON_NR = "Fyll i personnummer/orgnummer";
				$langInfo->TEXT_SUCCESSFUL_PAYMENT_COMMENT = "Köpet har godkänts av Klarna och fakturan från Klarna till dig har nummer: ";
				$langInfo->TEXT_CANCEL_REASON = "Klarna godkände ej köpet och angav följande anledning: ";
				$langInfo->TEXT_PURCHASE_CANCELLED_BASKET_SAVED = "Köp avbrutet, varukorgen är sparad";
				$langInfo->TEXT_RATE = "Ränta";
				$langInfo->TEXT_SHORT_MONTH = "mån";
				$langInfo->TEXT_FROM = "Från";
				$langInfo->TEXT_KLARNA_KONTO = "konto";
				$langInfo->TEXT_DISCOUNT = "Rabatt";
				$langInfo->TEXT_PAYMENT_INVOICE = "Faktura - Betala om 14 dagar";
				$langInfo->TEXT_PAYMENT_PART_PAYMENT = "Delbetalning";
				$langInfo->TEXT_PAYMENT_ACCOUNT = "Konto hos Klarna";
				$langInfo->TEXT_PAYMENT_CURRENCY_ERROR = "Vänligen välj samma valuta som ditt lands valuta och försök igen.";
				$langInfo->Country = "SWE";
				$GLOBALS['language'] = "SWE";
				return true;
				break;

			case "NOK":
			case "KRED_NOK":
			case "NO":
			case "no":
			case "NOR":
			case "nor":
			case "norweigan":
			case "Norweigan":
				$langInfo = new Singleton("Norway");
				$langInfo->TEXT_CHECKOUT_TITLE = "Betale på etterskudd";
				$langInfo->TEXT_INVOICE_SOCIAL_NR = "Personnummer/organisationsnummer";
				$langInfo->TEXT_SOCIAL_NR = "Personnummer";
				$langInfo->TEXT_PAYMENT_PHONE_NR_MOBILE = "Mobiltelefon";
				$langInfo->TEXT_PAYMENT_EMAIL = "E-postadresse";
				$langInfo->TEXT_PAYMENT_INVOICE_CONDITIONS = "Fakturavilkår";
				$langInfo->TEXT_PAYMENT_ANNUAL_SALARY = "Årsinntekt";
				$langInfo->TEXT_PAYMENT_TERMS = "Jeg godkjenner ";
				$langInfo->TEXT_PAYMENT_LINK_TERMS = "kontovilkårene";
				$langInfo->TEXT_PAYMENT_LINK_TERMS_2 = "";
				$langInfo->TEXT_PAYMENT_CHOOSE_MONTHLY_PAYMENT = "Velg antall måneder";
				$langInfo->TEXT_PAYMENT_REQUIRED = "Det Røde feltet er obligatoriske";
				$langInfo->TEXT_ADRESS_UPDATE_ALERT = "Leveranseadresse oppdatert i forhold til Folkeregistreret";
				$langInfo->TEXT_INVOICE_COST = "Fakturaavgift";
				$langInfo->TEXT_INFO_MISSING = "Ufullstendige opplysninger";
				$langInfo->TEXT_ACCEPT_CONDITIONS = "Du må godkjenne vilkårene";
				$langInfo->TEXT_MONTHLY_COST = "Månedskostnad";
				$langInfo->TEXT_MONTHS = "Måneder";
				$langInfo->LINK_CONDITIONS_PDF = "http://www.delauppbetalningen.se/kontovillkor.pdf";
				$langInfo->TEXT_CHECKOUT_ERR_BAD_PERSON_NR = "Feil format på personummer/orgnummer";
				$langInfo->TEXT_CHECKOUT_ERR_NO_PERSON_NR = "Fyll i personummer/orgnummer";
				$langInfo->TEXT_SUCCESSFUL_PAYMENT_COMMENT = "Kjøpet er nå godkjent av Klarna og fakturaen fra Klarna til deg har nummer: ";
				$langInfo->TEXT_CANCEL_REASON = "Klarna godkjente ikke kjøpet og gå følgende begrunnelse: ";
				$langInfo->TEXT_PURCHASE_CANCELLED_BASKET_SAVED = "Kjøpet ble avbrutt, handlekurven er lagret";
				$langInfo->TEXT_RATE = "Rente";
				$langInfo->TEXT_FROM = "Fra";
				$langInfo->TEXT_SHORT_MONTH = "mån";
				$langInfo->TEXT_KLARNA_KONTO = "konto";
				$langInfo->TEXT_DISCOUNT = "Rabatt";
				$langInfo->TEXT_PAYMENT_INVOICE = "Faktura- Betales om 14 dager";
				$langInfo->TEXT_PAYMENT_PART_PAYMENT = "Avbetaling";
				$langInfo->TEXT_PAYMENT_ACCOUNT = "Konto hos Klarna";
				$langInfo->TEXT_PAYMENT_CURRENCY_ERROR = "Velg samme valuta som tilhører ditt land og prøv igjen.";
				$langInfo->TEXT_PAYMENT_TOTAL_COST = "Total kredittkjøpspris";
				$langInfo->Country = "NOR";
				$GLOBALS['language'] = "NOR";
				return true;
				break;

			case "DKK":
			case "KRED_DKK":
			case "Danish":
			case "danish":
			case "Danska":
			case "danska":
			case "DNK":
			case "DK":
				$langInfo = new Singleton("Danish");
				$langInfo->TEXT_CHECKOUT_TITLE = "Betal efter levering";
				$langInfo->TEXT_INVOICE_SOCIAL_NR = "Personnummer/(CPR-nr)/PVR-nr";
				$langInfo->TEXT_SOCIAL_NR = "Personnummer";
				$langInfo->TEXT_PAYMENT_PHONE_NR_MOBILE = "Mobiltelefon";
				$langInfo->TEXT_PAYMENT_EMAIL = "E-mail";
				$langInfo->TEXT_PAYMENT_INVOICE_CONDITIONS = "Fakturavilkår";
				$langInfo->TEXT_PAYMENT_ANNUAL_SALARY = "Årsindkomst";
				$langInfo->TEXT_PAYMENT_TERMS = "Jeg godkender ";
				$langInfo->TEXT_PAYMENT_LINK_TERMS = "kontovilkårene";
				$langInfo->TEXT_PAYMENT_LINK_TERMS_2 = "";
				$langInfo->TEXT_PAYMENT_CHOOSE_MONTHLY_PAYMENT = "Vælg antal måneder";
				$langInfo->TEXT_PAYMENT_REQUIRED = "Det røde feldtet er obligatorisk";
				$langInfo->TEXT_ADRESS_UPDATE_ALERT = "Leveringsadresse blev opdateret til folkeregisteradresse";
				$langInfo->TEXT_INVOICE_COST = "Fakturaafgift";
				$langInfo->TEXT_INFO_MISSING = "Information savnes";
				$langInfo->TEXT_ACCEPT_CONDITIONS = "Du skal godkende vilkårene";
				$langInfo->TEXT_MONTHLY_COST = "Månedlig udgift";
				$langInfo->TEXT_MONTHS = "Måneder";
				$langInfo->LINK_CONDITIONS_PDF = "http://www.fakturermig.dk/kontovilkar.pdf";
				$langInfo->TEXT_CHECKOUT_ERR_BAD_PERSON_NR = "Forkert format på personnummer/organisationsnummer";
				$langInfo->TEXT_CHECKOUT_ERR_NO_PERSON_NR = "Udfyld personnummer/organisationsnummer";
				$langInfo->TEXT_SUCCESSFUL_PAYMENT_COMMENT = "Købet er nu godkendt af Klarna og fakturan fra Klarna til dig har nummer: ";
				$langInfo->TEXT_CANCEL_REASON = "Klarna godkendte ej købet og angav følgende anledning: ";
				$langInfo->TEXT_PURCHASE_CANCELLED_BASKET_SAVED = "Købet blev afbrudt, varekurven er gemt";
				$langInfo->TEXT_RATE = "Rente";
				$langInfo->TEXT_FROM = "Fra";
				$langInfo->TEXT_SHORT_MONTH = "mån";
				$langInfo->TEXT_KLARNA_KONTO = "konto";
				$langInfo->TEXT_DISCOUNT = "Rabat";
				$langInfo->TEXT_PAYMENT_INVOICE = "Faktura- Skal betales om 14 dage";
				$langInfo->TEXT_PAYMENT_PART_PAYMENT = "Afbetaling";
				$langInfo->TEXT_PAYMENT_ACCOUNT = "Konto hos Klarna";
				$langInfo->TEXT_PAYMENT_CURRENCY_ERROR = "Vælg den valuta som tilsvarar dit land og prøv igen.";
				$langInfo->Country = "DNK";
				$GLOBALS['language'] = "DNK";
				return true;
				break;

			case "FIN":
			case "KRED_EUR":
			case "Finska":
			case "finska":
			case "Suomi":
			case "suomi":
				$langInfo = new Singleton("Finnish");
				$langInfo->TEXT_CHECKOUT_TITLE = "Maksa jälkikäteen";
				$langInfo->TEXT_INVOICE_SOCIAL_NR = "Henkilötunnus/Y-tunnus";
				$langInfo->TEXT_SOCIAL_NR = "Henkilötunnus";
				$langInfo->TEXT_PAYMENT_PHONE_NR_MOBILE = "Matkapuhelinnumero";
				$langInfo->TEXT_PAYMENT_EMAIL = "Sähköpostiosoite";
				$langInfo->TEXT_PAYMENT_INVOICE_CONDITIONS = "Laskuehdot";
				$langInfo->TEXT_PAYMENT_ANNUAL_SALARY = "Vuositulot";
				$langInfo->TEXT_PAYMENT_TERMS = "Hyväksyn ";
				$langInfo->TEXT_PAYMENT_LINK_TERMS = "tiliehdot";
				$langInfo->TEXT_PAYMENT_LINK_TERMS_2 = "";
				$langInfo->TEXT_PAYMENT_CHOOSE_MONTHLY_PAYMENT = "Valitse osamaksuaika";
				$langInfo->TEXT_PAYMENT_REQUIRED = "Punaisella merkityt kentät ovat pakollisia";
				$langInfo->TEXT_ADRESS_UPDATE_ALERT = "Toimitusosoite on päivitetty väestörekisterissä olevaan osoitteeseen";
				$langInfo->TEXT_INVOICE_COST = "Laskutusmaksu";
				$langInfo->TEXT_INFO_MISSING = "Tietoja puuttuu";
				$langInfo->TEXT_ACCEPT_CONDITIONS = "Sinun täytyy hyväksyä ehdot";
				$langInfo->TEXT_MONTHLY_COST = "Kuukausikulut";
				$langInfo->TEXT_MONTHS = "Kuukautta";
				$langInfo->LINK_CONDITIONS_PDF = "http://kreditor.fi/_osamaksulla/osamaksulla_tiliehdot.pdf";
				$langInfo->TEXT_CHECKOUT_ERR_BAD_PERSON_NR = "Väärä muoto henkilö-/Y-tunnuksessa";
				$langInfo->TEXT_CHECKOUT_ERR_NO_PERSON_NR = "Täytä henkilö-/Y-tunnuskenttä";
				$langInfo->TEXT_SUCCESSFUL_PAYMENT_COMMENT = "Klarna on hyväksynyt oston ja laskun numero on: ";
				$langInfo->TEXT_CANCEL_REASON = "Klarna ei ole hyväksynyt ostostasi. Syy on seuraava: ";
				$langInfo->TEXT_PURCHASE_CANCELLED_BASKET_SAVED = "Osto keskeytetty, ostoskori on säilytetty";
				$langInfo->TEXT_RATE = "Korko";
				$langInfo->TEXT_FROM = "Alkaen";
				$langInfo->TEXT_SHORT_MONTH = "kk";
				$langInfo->TEXT_KLARNA_KONTO = "tili";
				$langInfo->TEXT_DISCOUNT = "Alennus";
				$langInfo->TEXT_PAYMENT_INVOICE = "Lasku - Maksuaikaa 14 vuorokautta";
				$langInfo->TEXT_PAYMENT_PART_PAYMENT = "Osamaksu";
				$langInfo->TEXT_PAYMENT_ACCOUNT = "Klarna Tili";
				$langInfo->TEXT_PAYMENT_CURRENCY_ERROR = "Valitse sama valuutta kuin maasi valuutta ja yritä sen jälkeen uudelleen.";
				$langInfo->Country = "FIN";
				$GLOBALS['language'] = "FIN";
				return true;
				break;

			case "ENG":
			case "english":
			case "English":
			case "Engelska":
			case "engelska":
				$langInfo = new Singleton("English");
				$langInfo->TEXT_CHECKOUT_TITLE = "Pay After Delivery";
				$langInfo->TEXT_INVOICE_SOCIAL_NR = "Social Security No/Org. No";
				$langInfo->TEXT_SOCIAL_NR = "Social Security No";
				$langInfo->TEXT_PAYMENT_PHONE_NR_MOBILE = "Phone number";
				$langInfo->TEXT_PAYMENT_EMAIL = "E-mail";
				$langInfo->TEXT_PAYMENT_INVOICE_CONDITIONS = "Conditions of purchase";
				$langInfo->TEXT_PAYMENT_ANNUAL_SALARY = "Annual Salary";
				$langInfo->TEXT_PAYMENT_TERMS = "I Agree on the ";
				$langInfo->TEXT_PAYMENT_LINK_TERMS = "account";
				$langInfo->TEXT_PAYMENT_LINK_TERMS_2 = "terms";
				$langInfo->TEXT_PAYMENT_CHOOSE_MONTHLY_PAYMENT = "Choose monthly payment";
				$langInfo->TEXT_PAYMENT_REQUIRED = "Redmarked fields are required";
				$langInfo->TEXT_ADRESS_UPDATE_ALERT = "Delivery adress has been updated to the nationally registered address.";
				$langInfo->TEXT_INVOICE_COST = "Invoice Cost";
				$langInfo->TEXT_INFO_MISSING = "Information missing";
				$langInfo->TEXT_ACCEPT_CONDITIONS = "Need to accept conditions";
				$langInfo->TEXT_MONTHLY_COST = "Monthly Cost";
				$langInfo->TEXT_MONTHS = "Months";
				$langInfo->LINK_CONDITIONS_PDF = "http://www.delauppbetalningen.se/kontovillkor.pdf";
				$langInfo->TEXT_CHECKOUT_ERR_BAD_PERSON_NR = "Wrong format on the Social Security No/Org. No";
				$langInfo->TEXT_CHECKOUT_ERR_NO_PERSON_NR = "Type in your Social Security No/Org. No";
				$langInfo->TEXT_SUCCESSFUL_PAYMENT_COMMENT = "The purchase has been approved by Klarna and the invoice from Klarna to you has number: ";
				$langInfo->TEXT_CANCEL_REASON = "Klarna did not approve the purchase and gave the following reason: ";
				$langInfo->TEXT_PURCHASE_CANCELLED_BASKET_SAVED = "The purchase has been aborted, the basket has been saved";
				$langInfo->TEXT_RATE = "Interest";
				$langInfo->TEXT_FROM = "From";
				$langInfo->TEXT_SHORT_MONTH = "month";
				$langInfo->TEXT_DISCOUNT = "Discount";
				$langInfo->TEXT_PAYMENT_INVOICE = "Invoice - Pay in 14 days";
				$langInfo->TEXT_PAYMENT_PART_PAYMENT = "Part payment";
				$langInfo->TEXT_PAYMENT_ACCOUNT = "Account at Klarna";
				$langInfo->TEXT_PAYMENT_CURRENCY_ERROR = "Please pick the currency for your country and try again.";
				$langInfo->Country = "ENG";
				$GLOBALS['language'] = "ENG";
				return true;
				break;

			case "DEU":
				$langInfo = new Singleton("German");
				$langInfo->TEXT_CHECKOUT_TITLE = "Nachnahme";
				$langInfo->TEXT_INVOICE_SOCIAL_NR = "Geburtstag";
				$langInfo->TEXT_SOCIAL_NR = "Geburtstag";
				$langInfo->TEXT_PAYMENT_PHONE_NR_HOME = "Festnetztelefonnummer";
				$langInfo->TEXT_PAYMENT_PHONE_NR_MOBILE = "Mobilnummer";
				$langInfo->TEXT_PAYMENT_EMAIL = "E-Mail";
				$langInfo->TEXT_PAYMENT_INVOICE_CONDITIONS = "Rechnungsbedingungen";
				$langInfo->TEXT_PAYMENT_ANNUAL_SALARY = "Jahreseinkommen";
				$langInfo->TEXT_PAYMENT_TERMS = "Ich akzeptiere die AGB";
				$langInfo->TEXT_PAYMENT_LINK_TERMS = "Kontobedingungen";
				$langInfo->TEXT_PAYMENT_LINK_TERMS_2 = "Bezeichnungen";
				$langInfo->TEXT_PAYMENT_CHOOSE_MONTHLY_PAYMENT = "Anzahl Monate auswählen";
				$langInfo->TEXT_PAYMENT_REQUIRED = "Die rot markierten Kästchen sind obligatorisch";
				$langInfo->TEXT_ADRESS_UPDATE_ALERT = "Die Lieferadresse wurde aktualisiert zur Meldeadresse";
				$langInfo->TEXT_INVOICE_COST = "Rechnungsgebühr";
				$langInfo->TEXT_INFO_MISSING = "Keine Information vorhanden";
				$langInfo->TEXT_ACCEPT_CONDITIONS = "Sie müssen die AGB akzeptieren";
				$langInfo->TEXT_MONTHLY_COST = "Monatliche Kosten";
				$langInfo->TEXT_MONTHS = "Monate";
				$langInfo->LINK_CONDITIONS_PDF = " http://www.delauppbetalningen.se/kontovillkor.pdf";
				$langInfo->TEXT_CHECKOUT_ERR_BAD_PERSON_NR = "Falsches Format des Geburtsdatums";
				$langInfo->TEXT_CHECKOUT_ERR_NO_PERSON_NR = "Geburtsdatum ausfüllen";
				$langInfo->TEXT_SUCCESSFUL_PAYMENT_COMMENT = "Die Bestellung wurde von Klarna akzeptiert und Ihre Klarna Rechnung hat die Nummer: ";
				$langInfo->TEXT_CANCEL_REASON = "Klarna konnte die Bestellung aus folgendem Grund nicht akzeptieren:";
				$langInfo->TEXT_PURCHASE_CANCELLED_BASKET_SAVED = "Der Einkauf wurde abgebrochen, der Warenkorb wurde gespeichert";
				$langInfo->TEXT_RATE = "Zinsen";
				$langInfo->TEXT_SHORT_MONTH = "Mon";
				$langInfo->TEXT_FROM = "Ab";
				$langInfo->TEXT_DISCOUNT = "Rabatt";
				$langInfo->TEXT_KLARNA_KONTO = "konto";
				$langInfo->TEXT_PAYMENT_GENDER = "Geschlecht";
				$langInfo->TEXT_PAYMENT_STREET_NAME = "Straße";
				$langInfo->TEXT_PAYMENT_STREET_NUMBER = "Hausnummer";
				$langInfo->TEXT_PAYMENT_GENDER_MALE = "Mann";
				$langInfo->TEXT_PAYMENT_GENDER_FEMALE = "Frau";
				$langInfo->TEXT_PAYMENT_INVOICE = "Rechnung - Zahlung innerhalb von 14 Tagen";
				$langInfo->TEXT_PAYMENT_PART_PAYMENT = "Finanzierung";
				$langInfo->TEXT_PAYMENT_ACCOUNT = "Konto bei Klarna";
				$langInfo->TEXT_PAYMENT_CURRENCY_ERROR = "Bitte wählen Sie Ihre Landeswährung und versuchen Sie es noch einmal.";
				$langInfo->Country = "DEU";
				$GLOBALS['language'] = "DEU";
				return true;
				break;

			case "NLD":
				$langInfo = new Singleton("Dutch");
				$langInfo->TEXT_CHECKOUT_TITLE = "Achteraf betalen";
				$langInfo->TEXT_INVOICE_SOCIAL_NR = "Geboortedatum";
				$langInfo->TEXT_PAYMENT_GENDER = "Geslacht";
				$langInfo->TEXT_PAYMENT_GENDER_MALE = "Man";
				$langInfo->TEXT_PAYMENT_GENDER_FEMALE = "Vrouw";
				$langInfo->TEXT_SOCIAL_NR = "Geboortedatum";
				$langInfo->TEXT_PAYMENT_PHONE_NR_HOME = "Telefoon";
				$langInfo->TEXT_PAYMENT_PHONE_NR_MOBILE = "Mobiel telefoonnummer";
				$langInfo->TEXT_PAYMENT_EMAIL = "E-mail";
				$langInfo->TEXT_PAYMENT_STREET_NAME = "Straatnaam";
				$langInfo->TEXT_PAYMENT_STREET_NUMBER = "Straatnummer";
				$langInfo->TEXT_PAYMENT_HOUSE_EXTENSION = "Toevoeging";
				$langInfo->TEXT_PAYMENT_INVOICE_CONDITIONS = "Factuurvoorwaarden";
				$langInfo->TEXT_PAYMENT_ANNUAL_SALARY = "Jaarlijks inkomen";
				$langInfo->TEXT_PAYMENT_TERMS = "Ik ga akkoord met de voorwaarden ";
				$langInfo->TEXT_PAYMENT_LINK_TERMS = "Accountvoorwaarden";
				$langInfo->TEXT_PAYMENT_LINK_TERMS_2 = "";
				$langInfo->TEXT_PAYMENT_CHOOSE_MONTHLY_PAYMENT = "Kies aantal maanden";
				$langInfo->TEXT_PAYMENT_REQUIRED = "De roodgemarkeerde velden zijn verplicht";
				$langInfo->TEXT_ADRESS_UPDATE_ALERT = "Het leveringsadres wordt geüpdate naar het domicilieadres.";
				$langInfo->TEXT_INVOICE_COST = "Factuurkost";
				$langInfo->TEXT_INFO_MISSING = "Informatie ontbreekt";
				$langInfo->TEXT_ACCEPT_CONDITIONS = "U moet de voorwaarden goedkeuren";
				$langInfo->TEXT_MONTHLY_COST = "Maandelijkse kost";
				$langInfo->TEXT_MONTHS = "Maanden";
				$langInfo->LINK_CONDITIONS_PDF = " http://www.delauppbetalningen.se/kontovillkor.pdf";
				$langInfo->TEXT_CHECKOUT_ERR_BAD_PERSON_NR = "Verkeerd geformuleerde geboortedatum";
				$langInfo->TEXT_CHECKOUT_ERR_NO_PERSON_NR = "Vul geboortedatum in";
				$langInfo->TEXT_SUCCESSFUL_PAYMENT_COMMENT = "De aankoop werd goedgekeurd door Klarna en het factuurnummer is: ";
				$langInfo->TEXT_CANCEL_REASON = "Klarna heeft de aankoop niet goedgekeurd door de volgende rede: ";
				$langInfo->TEXT_PURCHASE_CANCELLED_BASKET_SAVED = "Aankoop werd onderbroken, de winkelwagen is opgeslagen";
				$langInfo->TEXT_RATE = "Rente";
				$langInfo->TEXT_SHORT_MONTH = "maand";
				$langInfo->TEXT_FROM = "Van";
				$langInfo->TEXT_KLARNA_KONTO = "Account";
				$langInfo->TEXT_DISCOUNT = "Korting";
				$langInfo->TEXT_PAYMENT_INVOICE = "Factuur - Betaal over 14 dagen";
				$langInfo->TEXT_PAYMENT_PART_PAYMENT = "Deelbetaling";
				$langInfo->TEXT_PAYMENT_ACCOUNT = "Account bij Klarna";
				$langInfo->TEXT_PAYMENT_CURRENCY_ERROR = "Gelieve het valuta van uw land te kiezen en opnieuw te proberen.";
				$langInfo->Country = "NLD";
				$GLOBALS['language'] = "NLD";
				return true;
				break;

			default:
				echo '<br />' . $strLang . '<br />';
				echo "Setting Klarna Language Error! - unknown language!<br />";
				break;
		}

		return false;
    }
}

class Singleton {
	private static $values = NULL;

	public function __construct($param)
	{
		if (Singleton::$values == NULL) {
			Singleton::$values = array('param' => $param);
		}
	}

	public function __set($name, $value)
	{
		return Singleton::$values[$name] = $value;
	}

	public function __get($name)
	{
		return Singleton::$values[$name];
	}

	public function __unset($name)
	{
		if (array_key_exits($name, Singleton::$values)) {
			unset(Singleton::$values[$name]);
		}
	}

	public function __isset($name)
	{
		return array_key_exists($name, Singleton::$values);
	}

	public function __toString()
	{
		$ar = array();
		foreach (Singleton::$values as $name => $value) {
			$ar[] = "this->$name = $value";
		}
		return implode("\n", $ar);
	}

	public function func($title)
	{
		//echo "dumping instance $title\n";
		foreach(Singleton::$values as $key => $value) {
			echo "this->$key: " . $this->$key . "\n";
		}
	}
}

?>
